package com.ssy.lingxi.pay.common;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 交易项目
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/7/21
 */
public enum TradeOperationEnum {

    AccountRecharge(1, "账户充值"),
    AccountCashOut(2, "账户提现"),
    OrderPay(3, "订单支付"),
    OrderRefund(4, "订单退款"),
    OrderRebate(5, "订单返利");

    private Integer code;

    TradeOperationEnum(Integer code, String message) {
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(),this.code);
    }

    public static String getMessage(Integer code){
        TradeOperationEnum workEnum = Arrays.stream(TradeOperationEnum.values()).filter(v -> v.getCode().equals(code)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(TradeOperationEnum.class, workEnum.getCode());
    }
}
